<?php
// +----------------------------------------------------------------------
// | quanli team
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.fistforward.com/ All rights reserved.
// +----------------------------------------------------------------------
// | Author: allen.qiang
// +----------------------------------------------------------------------

/**
 * 公共商品ajax类
 * @package  ajax/comm/goods
 * @author   allen.qiang
 */

quanli_require('module/base/goods/quanliGoods.class.php');

class ajax_commGoods {

    public function execute() {

        if ( isset($_REQUEST['operFlg']) && quanli_is_int($_REQUEST['operFlg']) ) {

            switch ( $_REQUEST['operFlg'] ) {

                case 1: //查询三级商品详情
                    $this->searchThreeLevelGoodsDetail();
                    break;

                default:
                    returnJsonData('参数错误');
                    break;

            }

        } else {

            returnJsonData('参数错误');

        }

    }

    /**
     * 查询三级商品详情
     */
    private function searchThreeLevelGoodsDetail() {

        global $G_SHOP;

        if ( !isset($_REQUEST['product_code'], $_REQUEST['cityID']) || empty($_REQUEST['product_code']) || !quanli_is_int($_REQUEST['cityID']) ) {
            returnJsonData('参数错误');
        }

        //实例商品类
        $quanliGoods = new quanliGoods( $G_SHOP->DBCA );

        //查询三级商品商品信息
        $arg_array = array(
            'product_code' => $_REQUEST['product_code'],
            'cityID' => $_REQUEST['cityID']
        );
        $goods_array = $quanliGoods->searchGoodsSaleDetail( $arg_array );

        if ($goods_array) {

            returnJsonData('ok', 200, $goods_array);

        } else {

            returnJsonData('商品信息没有找到', 404);

        }

    }

}